package com.study.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController//将当前类交给Spring容器管理
@PropertySource(value = "classpath:/name.properties",encoding = "utf-8")
public class HelloController {

    //private String name; = "李四";
    @Value("${stuname}")
    //@Value的作用是从 spring容器中获取数据，获取数据时需要指定key
    private String name;


    @Value("${stuname2}")
    private String name2;


    /**
     * 完成欢迎页面
     * http://localhost:8080/getName
     * 返回值：变量的name属性
     */

    @RequestMapping("/getName")
    public String getName(){
        return name + "|" +name2;
    }
}
